package com.yyl.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.yyl.common.pojo.PictureResult;
import com.yyl.common.utils.JsonUtils;
import com.yyl.service.PictureService;

@Controller
public class PictureController {
	
	@Autowired
	private PictureService pictureService;
	
	@RequestMapping("/pic/upload")
	@ResponseBody
	public String uploadPicture(MultipartFile uploadFile) throws Exception {
		
		PictureResult pictureResult = pictureService.uploadPicture(uploadFile);
		//需要把Java对象手动转换成json数据
		String pictureResultJson = JsonUtils.objectToJson(pictureResult);
		return pictureResultJson;
	}
}
